# coding: utf8

'''

'''
CITY_SIZE=25
STATE_SIZE=25
newline = '\n'
default_street= T('123 Some Street')
default_city=T('Montréal')
default_province="Québec"
default_country = 'Canada'
default_postal_code= 'H2P 1M5'
default_address = 'street' + newline + default_city + ',' + default_province
default_address_type = 1

default_phone_type=3

phone_length = 20

db.define_table('donor',
    Field('first_name',
        label=T("First Name")),
    Field('last_name',
        label=T("Last Name")),
    audit_table
    )

db.define_table('address_type',
    Field('name',default=default_address_type,
             label=T("Address Type")),
    audit_table
    )

db.define_table('address',
#    Field('auth_user_id',db.auth_user,writable=False,readable=False),
    Field('donor_id',db.donor,
            writable=False,readable=False),
    Field('address_type_id', db.address_type, default=default_address_type, writable=False, readable=False),
    Field('address', "text",
             length=255, default=default_street, 
             label=T("Address")),
    Field('city', length=CITY_SIZE, default=default_city, label=T("City")),
    Field('province', length=STATE_SIZE, default=default_province, 
          label=T("Province/State")),
    Field('postal_code', length=8, default=None, label=T("Postal Code"),
          comment=T("Enter the postal or zip code")),
#    Field('address_display', type='text',default=default_address),
    audit_table
    )

db.address.donor_id.requires = IS_IN_DB(db,"donor.id","%(name)s")
db.address.address_type_id.requires = IS_IN_DB(db,"address_type.id","%(name)s")
db.address.address_type_id.requires = IS_IN_DB(db,"address_type.id","%(name)s")

db.define_table('phone_type',
    Field('name'),
    audit_table
    )

db.define_table('phone',
    Field('phone_type_id', db.phone_type, default=default_phone_type,
          label=T("Phone Type"),
          comment=T("Phone type comment")),          
    Field('number', length=phone_length, default=None, 
          label=T("Telephone Number"),
          comment=T("(514) 384-6672 ot 514.384.6672 etx 6")),
    audit_table,
    )

db.phone.phone_type_id.requires = IS_IN_DB(db, 'phone_type.id', '%(name)s')
